package com.cloud.freeflow.api.web;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.cloud.freeflow.api.entity.ProcActEvent;
import com.cloud.freeflow.api.service.ProcEventService;
import com.cloud.freeflow.common.result.Quokka;

@RestController
@RequestMapping("freeflow/api/procevent")
public class ProcEventController {
	
	@Autowired
	private ProcEventService procEventService;
	
	@GetMapping("/list")
	public Quokka listEventsByActDefId(long actDefId){
		return new Quokka(true, procEventService.listEventsByActDefId(actDefId));
	}
	
	@GetMapping("/delete")
	public Quokka deleteEvent(long eventId){
		procEventService.deleteEvent(eventId);
		return new Quokka(true);
	}
	
	@PostMapping("/saveupdate")
	public Quokka saveUpdateEvent(@RequestBody ProcActEvent event){
		return new Quokka(true, procEventService.saveUpdateEvent(event));
	}
}
